import math
import numpy as np

# isFirst要么传1,要么传-1
def method(L, qiJiao=32 * math.pi, isFirst=1):
    L0 = L

    a = 0.55 / (2 * math.pi)

    A = qiJiao * (1 / math.cos(np.arctan(qiJiao))) + np.arctan(qiJiao)

    low = 0
    high = qiJiao * (10 ** 12)

    result = 0

    while low <= high:
        mid = (low + high) / 2
        x = mid / 10 ** 12
        fx = a / 2 * (A - x * 1 / math.cos(np.arctan(x)) - np.arctan(x)) * isFirst
        if math.fabs(fx - L0) <= 10 ** (-12):
            result = x
            break
        if fx < L0:
            high = mid - 1
        else:
            low = mid + 1

    if result == 0:
        result = mid / 10 ** 12
    return result
